package com.lock.chess.Enums;

public enum LevelEnum {
    BING_V("兵Ⅴ", 0), // 兵五
    BING_IV("兵Ⅳ", 1), // 兵四
    BING_III("兵Ⅲ", 2), // 兵三
    BING_II("兵Ⅱ", 3), // 兵二
    BING_I("兵Ⅰ", 4), // 兵一
    SHI_V("士Ⅴ", 5), SHI_IV("士Ⅳ", 6), SHI_III("士Ⅲ", 7), SHI_II("士Ⅱ", 8), SHI_I("士Ⅰ", 9),
    MA_V("马Ⅴ", 10), MA_IV("马Ⅳ", 11), MA_III("马Ⅲ", 12), MA_II("马Ⅱ", 13), MA_I("马Ⅰ", 14),
    CHE_V("车Ⅴ", 15), CHE_IV("车Ⅳ", 16), CHE_III("车Ⅲ", 17), CHE_II("车Ⅱ", 18), CHE_I("车Ⅰ", 19),
    XIANG_V("相Ⅴ", 20), XIANG_IV("相Ⅳ", 21), XIANG_III("相Ⅲ", 22), XIANG_II("相Ⅱ", 23), XIANG_I("相Ⅰ", 24),
    PAO_V("炮Ⅴ", 25), PAO_IV("炮Ⅳ", 26), PAO_III("炮Ⅲ", 27), PAO_II("炮Ⅱ", 28), PAO_I("炮Ⅰ", 29),
    JIANG_V("将Ⅴ", 30), JIANG_IV("将Ⅳ", 31), JIANG_III("将Ⅲ", 32), JIANG_II("将Ⅱ", 33), JIANG_I("将Ⅰ", 34);
    private String name;
    private int value;

    LevelEnum(String name, int value)
    {
        this.name = name;
        this.value = value;
    }

    public String getName()
    {
        return name;
    }

    public static LevelEnum getLevel(String name){
        for (LevelEnum level : LevelEnum.values()) {
            if(level.getName().equals(name)){
                return level;
            }
        }
        return null;
    }

    public static LevelEnum getLevelByValue(int value){
        for (LevelEnum level : LevelEnum.values()) {
            if(level.value == value){
                return level;
            }
        }
        return null;
    }

    public static LevelEnum getNextLevel(LevelEnum level){
        System.out.println(level.value);
        System.out.println(level.name);
        if(level.value != 6){
            return getLevelByValue(level.value+1);
        }else{
            return level;
        }

    }

    public static LevelEnum getPrevLevel(LevelEnum level){
        if(level.value != 0){
            return getLevelByValue(level.value-1);
        }else{
            return level;
        }

    }

}
